//  Android Carpool System
//  2011-2011
//  Author: Jinhuan Wang
//  name:  Signup.java
//  description: insert new account into data base
//$history: /carpoolservice/scr/com/carpool/service/Signup.java$
/*************************************************/
package com.carpool.service;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@SuppressWarnings("serial")
public class Signup  extends HttpServlet {
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws IOException, ServletException {
		DBOperation DBO = new DBOperation();
		boolean returnflag = false;
		String cellphone = null;
		String uname = null;
		String password = null;
		try {
			InputStream is = request.getInputStream();
			DataInputStream dis = new DataInputStream(is);
			uname = dis.readUTF();
			password = dis.readUTF();
			cellphone = dis.readUTF();
			returnflag = DBO.register(uname, password, cellphone);
			DataOutputStream dos = new DataOutputStream(response
					.getOutputStream());
			dos.writeBoolean(returnflag);
			dos.flush();
			dos.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public void doGet(HttpServletRequest request, HttpServletResponse response)
	throws IOException, ServletException {doPost( request, response);}

}

